package cn.topevery.garden.dal.dao.impl;

import cn.topevery.garden.dal.dao.ProjStageFileCodeDao;
import cn.topevery.garden.entity.po.ProjStageFileCode;
import cn.topevery.garden.entity.query.ProjStageFileCodeQuery;
import cn.topevery.garden.entity.vo.ProjStageFileCodeVO;
import cn.topevery.garden.framework.base.BaseDaoImpl;
import hw.topevery.framework.db.entity.DataPager;
import hw.topevery.framework.db.entity.SqlQueryMate;
import hw.topevery.framework.db.enums.ScriptConditionEnum;
import hw.topevery.framework.entity.DbCsp;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

/**
 * 项目阶段附件编码维护表
 *
 * @author code-generate
 * @date 2022-11-02
 */
@Repository
public class ProjStageFileCodeDaoImpl extends BaseDaoImpl<ProjStageFileCode> implements ProjStageFileCodeDao {
    @Override
    public <P extends DbCsp> List<ProjStageFileCode> getSearch(P para) {
        return null;
    }

    

    @Override
    public DataPager<ProjStageFileCodeVO> listPage(ProjStageFileCodeQuery query) {
        Integer pageIndex = query.pageIndex - 1;
        String table = "t_proj_stage_file_code tpsfc";

        String columns = "tpsfc.*";

        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns).setOrderBy("tpsfc.c_id desc");
        sqlQueryMate
                .where(true, "tpsfc.c_db_status", ScriptConditionEnum.Eq, 0)
        ;

        return getDataPager(sqlQueryMate, query.pageSize, pageIndex, ProjStageFileCodeVO.class);
    }

    @Override
    public void saveOrUpdate(String userId, Class<ProjStageFileCode> entityClass, ProjStageFileCode entity) {

    }

    @Override
    public void saveOrUpdate(String userId, Class<ProjStageFileCode> entityClass, Collection<ProjStageFileCode> list) {

    }

    @Override
    public List<ProjStageFileCodeVO> getByStageTypeCode(String stageTypeCode) {
        String table = "t_proj_stage_file_code tpsfc";

        String columns = "tpsfc.*";

        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns).setOrderBy("tpsfc.c_order_num, c_db_create_date desc");
        sqlQueryMate
                .where(true, "tpsfc.c_db_status", ScriptConditionEnum.Eq, 0)
                .where(true, "tpsfc.c_proj_stage_type_code", ScriptConditionEnum.Eq, stageTypeCode)
        ;

        return selectList(sqlQueryMate, ProjStageFileCodeVO.class);
    }
}
